load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "gcworker",
    srcs = ["gc_worker.go"],
    importpath = "github.com/pingcap/tidb/store/gcworker",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/utils",
        "//ddl",
        "//ddl/label",
        "//ddl/placement",
        "//ddl/util",
        "//domain/infosync",
        "//kv",
        "//metrics",
        "//parser/model",
        "//parser/terror",
        "//privilege",
        "//session",
        "//sessionctx",
        "//sessionctx/variable",
        "//tablecodec",
        "//util/chunk",
        "//util/codec",
        "//util/dbterror",
        "//util/logutil",
        "//util/sqlexec",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/errorpb",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_tikv_client_go_v2//error",
        "@com_github_tikv_client_go_v2//kv",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@com_github_tikv_client_go_v2//txnkv/rangetask",
        "@com_github_tikv_client_go_v2//txnkv/txnlock",
        "@com_github_tikv_client_go_v2//util",
        "@com_github_tikv_pd_client//:client",
        "@org_golang_x_exp//slices",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "gcworker_test",
    timeout = "short",
    srcs = [
        "gc_worker_test.go",
        "main_test.go",
    ],
    embed = [":gcworker"],
    flaky = True,
    race = "on",
    shard_count = 30,
    deps = [
        "//ddl/placement",
        "//ddl/util",
        "//domain",
        "//domain/infosync",
        "//kv",
        "//parser/model",
        "//session",
        "//store/mockstore",
        "//testkit/testmain",
        "//testkit/testsetup",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/errorpb",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//oracle/oracles",
        "@com_github_tikv_client_go_v2//testutils",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@com_github_tikv_client_go_v2//txnkv/txnlock",
        "@com_github_tikv_pd_client//:client",
        "@org_uber_go_goleak//:goleak",
    ],
)
